import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:search_people/utils/component/selection/index.dart';

import '../../../../value/topcolors.dart';
import '../model.dart';

class SelectionListWidget extends GetView<SelectionController> {
  const SelectionListWidget({
    Key? key,
    required this.index,
    required this.selectedIndex,
    required this.md,
    this.onTap,
    this.onChoosedTap,
  }) : super(key: key);
  final int index;
  final int selectedIndex;
  final SelectionModel md;
  final Function()? onTap;
  final Function()? onChoosedTap;
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        height: 50.r,
        padding: EdgeInsets.only(left: 10.r),
        alignment: Alignment.centerLeft,
        decoration: BoxDecoration(
          color: selectedIndex == index ? TopColors.gray_f3 : Colors.white,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Flexible(
              child: Container(
                height: 50.r,
                alignment: Alignment.centerLeft,
                child: Text(
                  md.title,
                  style: TextStyle(
                    color: TopColors.black_33,
                    fontSize: 15.sp,
                  ),
                  softWrap: true,
                  overflow: TextOverflow.ellipsis,
                ),
              ),
            ),
            InkWell(
              onTap: onChoosedTap,
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 10.r, vertical: 13.r),
                child: Icon(
                  Icons.check_box_rounded,
                  color: md.isSelected ? TopColors.main_color : TopColors.bg,
                  size: 24.r,
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
